home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: kakima@ix.netcom.com (Kiyoshi Akima)
- Newsgroups: comp.lang.c++
- Subject: Re: for (int i(1); ...)
- Date: 7 Mar 1996 00:58:37 GMT
- Organization: Netcom
- Message-ID: <4hlcbt$1lf@dfw-ixnews4.ix.netcom.com>
- References: <4gg2j6$93g@darkstar.UCSC.EDU> <ltwx5fuqn8.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de> <4hjefu$sbd@waldorf.csc.calpoly.edu>
- NNTP-Posting-Host: den-co5-06.ix.netcom.com
- X-NETCOM-Date: Wed Mar 06 6:58:37 PM CST 1996
-
- In <4hjefu$sbd@waldorf.csc.calpoly.edu> ostoll@galaxy.csc.calpoly.edu
- (Oliver Stoll) writes:
- >
- >At htis point i just wanted to mention another incompatibility I have
- >noticed. There is a difference between AIX's xlC and g++ as for that
- >definition (so if you want to write portable code, define the variable
- >at the beginning of the function;):
- >
- >In xlC the scope of a variable defined in for(int i = 0, ...) is the
- >complete function the for() statement is contained in. In g++ however,
- >the validity of the int declared like that is only the for statement.
- >So if you write a program on AIX using i after the for statement to
- >decide the end vlue of the for perhaps, and compile the program on xlC
- >it will report you an undefined variable. And if you use the same i
- >with for(int i...) in two subsequent for calls with g++ AIX will tell
- >you in the second for statement that i is already defined so...
- >
-
- Seems to me that the xlC compiler hasn't caught up with the current
- status of the C++ standardization process. The scope of a variable
- declared in the for statement is supposed to be just the for statement.
- g++ does have a switch to make it behave the old way.
-
- Kiyoshi Akima
- kakima@ix.netcom.com
-
-